package com.santiao.fuel.ui.activity

import android.annotation.SuppressLint
import android.os.Bundle
import android.text.Html
import android.text.TextUtils
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.santiao.fuel.R
import com.santiao.fuel.utils.DisplayUtil
import com.santiao.publics.ui.SettingFragment
import org.w3c.dom.Text


/**
 * 安全问题列表和燃气使用科普列表的公用详情页
 */
class GasGuideDetails : AppCompatActivity() {

    companion object {
        val  PAGE_TITLE =  "page_title"
        val  PAGE_DESC =  "page_desc"
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_gas_guide_details)
        initData();
        initView();
        SettingFragment.adLoad(1, null, findViewById(R.id.fl_content_1), this, this)
    }

    @SuppressLint("SetTextI18n")
    private fun initData() {
        val pageTitle = intent.getStringExtra(PAGE_TITLE)
        val pageDesc = intent.getStringExtra(PAGE_DESC)
        val gasBarRootView = findViewById<RelativeLayout>(R.id.gas_bar)
        val page_title = gasBarRootView.findViewById<TextView>(R.id.page_title)
        val page_back = gasBarRootView.findViewById<ImageView>(R.id.page_back)
        val desc = findViewById<TextView>(R.id.desc)

        // 设置页面标题
        if (!TextUtils.isEmpty(pageTitle)){
            page_title.text = pageTitle
        }else{
            page_title.text  = "UNKNOWN TITLE"
        }
        page_back.setOnClickListener {
            finish()
        }
        // 设置页面内容
        if (!TextUtils.isEmpty(pageDesc)){
            desc.text = Html.fromHtml(pageDesc)
        }else{
            desc.text = "暂无内容"
        }


    }

    private fun initView() {

        DisplayUtil.initActionBar(this)
    }
}